# Maintainer: Daniel Bershatsky <bepshatsky@yandex.ru>
pkgname=python-chex
_pkgname=${pkgname#python-}
pkgver=0.1.91
pkgrel=3
pkgdesc="A library of utilities for helping to write reliable JAX code"
arch=('any')
url="https://github.com/google-deepmind/chex"
license=('Apache-2.0')
groups=('deepmind' 'jax')
depends=('python-absl'
         'python-jax>=0.4.27'
         'python-numpy'
         'python-toolz'
         'python-typing_extensions')
makedepends=("python-build" "python-flit-core" "python-installer"
             'python-wheel')
checkdepends=('python-cloudpickle' 'python-dm-tree' 'python-pytest')
source=("$_pkgname-$pkgver.tar.gz::https://github.com/google-deepmind/$_pkgname/archive/refs/tags/v$pkgver.tar.gz")
sha256sums=('0e67bc74c6914f4515c45927ff396c3d242e7fd9fe5c1da45ec937b85ccfaefc')

build() {
    python -m build -nw "$_pkgname-$pkgver"
}

check() {
    cd "$_pkgname-$pkgver"
    export PYTHONPATH=$PWD
    pytest -v -s chex
}

package() {
    cd "$_pkgname-$pkgver"
    install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
    python -m installer --compile-bytecode=1 --destdir=$pkgdir \
        dist/$_pkgname-$pkgver-*.whl
}
